<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
use Illuminate\Support\Facades\Auth;

class MustVerifyEmail
{
    /**
     * Handle an incoming request.
     *
     * @param $request
     * @param  $next
     * @return mixed
     */
    public function handle($request, $next)
    {
        if (Auth::user()->email_verified_at==null) {
            return redirect('email/verify');
        }
        return $next($request);
    }
}
